<% add_decidim_page_title(t("decidim.admin.titles.area_types")) %>
<div class="card" id="area-types">
  <div class="item_show__header">
    <h1 class="item_show__header-title">
      <%= t "decidim.admin.titles.area_types" %>
      <% if allowed_to? :create, :area_type %>
        <%= link_to t("actions.add", scope: "decidim.admin"), [:new, :area_type], class: "button button__sm button__secondary new" %>
      <% end %>
    </h1>
  </div>

  <div class="flash warning"><%= t("areas.deprecated", scope: "decidim.admin") %></div>

  <div class="table-stacked">
      <table class="table-list">
      <thead>
        <tr>
          <th><%= t("models.area_type.fields.name", scope: "decidim.admin") %></th>
          <th><%= t("models.area_type.fields.plural", scope: "decidim.admin") %></th>
          <th><%= t("decidim.admin.actions.actions") %></th>
        </tr>
      </thead>
      <tbody>
        <% area_types.each do |area_type| %>
          <tr>
            <td data-label="<%= t("models.area_type.fields.name", scope: "decidim.admin") %>">
              <% if allowed_to? :update, :area_type, area_type: area_type %>
                <%= link_to translated_attribute(area_type.name), [:edit, area_type] %>
              <% else %>
                <%= translated_attribute(area_type.name) %>
              <% end %>
            </td>
            <td data-label="<%= t("models.area_type.fields.plural", scope: "decidim.admin") %>">
              <%= translated_attribute(area_type.plural) %>
            </td>
            <td class="table-list__actions" data-label="<%= t("decidim.admin.actions.actions") %>">
              <button type="button" data-controller="dropdown" data-target="actions-area-type-<%= area_type.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: translated_attribute(area_type.name)) %>">
                <%= icon "more-fill", class: "text-secondary" %>
              </button>

              <div class="inline-block relative">
                <ul id="actions-area-type-<%= area_type.id %>" class="dropdown dropdown__action" aria-hidden="true">
                  <% if allowed_to? :update, :area_type, area_type: area_type %>
                    <li class="dropdown__item">
                      <%= link_to [:edit, area_type], method: :get, class: "dropdown__button" do %>
                        <%= icon "pencil-line" %>
                        <%= t("actions.edit", scope: "decidim.admin") %>
                      <% end %>
                    </li>
                  <% end %>

                  <% if allowed_to? :destroy, :area_type, area_type: area_type %>
                    <hr>

                    <li class="dropdown__item">
                      <%= link_to area_type, method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") }, class: "dropdown__button" do %>
                        <%= icon "delete-bin-line" %>
                        <%= t("actions.destroy", scope: "decidim.admin") %>
                      <% end %>
                    </li>
                  <% end %>
                </ul>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
